<template>
  <div>
      <div class="head">
          <div>{{para.sourceName}}</div>
      </div>
      <div class="form">
          <input v-model="para.company" type="text" placeholder="请填写公司">
          <input v-model="para.name" type="text" placeholder="请填写联系人">
          <input v-model="para.contact" type="text" placeholder="请填写联系电话">
          <div class="btn" @click="submit">提交</div>
      </div>
  </div>
</template>
<script>
import { Get, Post, Port } from "../../server/ajax";
import { Toast } from "mint-ui";
export default {
  data() {
    return {
      para: {
        company: null,
        name: null,
        contact: null,
        sourceName: "",
        source: 2
      }
    };
  },
  created() {
    this.$parent.tState = 1;
    this.$parent.fState = 1;
  },
  activated() {
    this.para = {
      company: null,
      name: null,
      contact: null,
      sourceName: "",
      source: 2
    };
    this.$parent.updata();
    if (this.$route.params.id == 1) {
      this.para.sourceName = this.$route.params.title;
      this.para.source = 1;
    }
    if (this.$route.params.id == 2) {
      this.para.sourceName = this.$route.params.title + "咨询";
    }
    if (this.$route.params.id == 3) {
      this.para.sourceName = this.$route.params.title;
    }
  },
  methods: {
    submit() {
      if (!this.para.company || !this.para.name || !this.para.contact) {
        Toast("请正确填写后提交！");
        return;
      }
      Post(
        "http://wwwtest.aiyuangong.com/cms/api/mobileContact",
        this.para,
        function(data) {
          console.log(data);
          if (data) {
            Toast("您的信息我们已经收到！稍候我们将有专人与您联系。");
          }
        }
      );
    }
  }
};
</script>
<style scoped>
.head {
  height: 1.6rem;
  padding-top: 0.6rem;
  background-size: cover;
  background-image: url("~@/assets/consult/banner.png");
}
.head > div {
  font-size: 0.38rem;
  color: #fff;
  /* font-weight: bold; */
  text-align: center;
}
.head > div::before {
  content: "";
  position: relative;
  top: 0.1rem;
  margin-right: 0.25rem;
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  background-size: cover;
  background-image: url("~@/assets/consult/icon.png");
}
.form {
  padding: 0.4rem;
}
input {
  height: 1rem;
  line-height: 1rem;
  font-size: 0.32rem;
  color: #333;
  margin-top: 0.2rem;
  width: 100%;
  box-shadow: unset;
  outline: unset;
  border: unset;
  border-bottom: 0.02rem solid #ededed;
}
input:focus {
  border-bottom: 0.02rem solid #ed5172;
}
.btn {
  width: 3.5rem;
  height: 0.84rem;
  border-radius: 0.42rem;
  font-size: 0.32rem;
  line-height: 0.84rem;
  text-align: center;
  color: #fff;
  background-color: #ed5172;
  margin: 1rem auto 3.36rem;
}
</style>
